package com.qiangqiang.task.server.mapper.provider;

import com.qiangqiang.task.server.entity.Post;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * @program: task
 * @description:
 * @author: Sky.lin
 * @create: 2018-12-20 20:03
 **/
public class PostMapperProvider extends BaseProvider{

    public String insertPost(final Map<String,Object> map){
        Post post= (Post) map.get("post");
        return generateInsertSQL(Post.class);
    }

    public String queryAllPost(final Map<String,Object> map){
        final int page= (int) map.get("page");
        final int pageSize= (int) map.get("pageSize");

        SQL sql = new SQL() {
            {
                SELECT("*");
                FROM("post ");
                ORDER_BY("update_time desc ");
            }
        };
        StringBuffer sb = new StringBuffer(sql.toString());
        sb.append(getLimit(page, pageSize));
        return sb.toString();
    }
}
